package org.cloudnote.mapper;

import org.apache.ibatis.session.SqlSessionFactory;

import org.cloudnote.bean.Note;
import org.cloudnote.bean.NoteBook;
import org.cloudnote.bean.User;
import org.cloudnote.util.SpringTest;
import org.junit.Test;

import javax.sql.DataSource;
import java.util.List;

public class MapperTest extends SpringTest {
    @Test
    public void test1(){
        DataSource ds = super.getContext().getBean("dbcp", DataSource.class);
        System.out.println("ds = " + ds);
    }
    @Test
    public void test2() {
        SqlSessionFactory sqlSessionFactory =super.getContext()
                .getBean("sqlsessionFactory", SqlSessionFactory.class);
        System.out.println("sqlSessionFactory = " + sqlSessionFactory);
    }
    @Test
    public void test3() {
        UserMapper userMapper = super.getContext().getBean("userMapper", UserMapper.class);
        User user = userMapper.getByName("zhouj");
        if (user == null) {
            System.out.println("用户名不存在");
        }else{

        }
    }
    @Test
    public void test4(){
        NoteBookMapper noteBookMapper = super.getContext().getBean("noteBookMapper", NoteBookMapper.class);
        List<NoteBook> noteBooks = noteBookMapper.selectByUserId("39295a3d-cc9b-42b4-b206-a2e7fab7e77c");
        for (NoteBook noteBook : noteBooks) {
            System.out.println(noteBook);
        }
    }
    @Test
    public void test5(){
        NoteMapper noteMapper = super.getContext().getBean("noteMapper", NoteMapper.class);
        Note notes = noteMapper.getByNoteId("6d763ac9-dca3-42d7-a2a7-a08053095c08");

    }

}

